{layout name="public/layout" /}
{include file='yxnavbar'}


<style type="text/css">
    .tuan_div{
        height: 36px;
    }
    .tuan_div300{
        height: 200px;
    }
    .tuan_title{
        width: 140px;
        text-align: right;
        font-size: 14px;
        color: #606266;
        font-weight: 700;
        padding-right: 12px;
    }
    .right_btn{
        display: inline-block;
        float: right;
        border: 1px solid #ff4949;
        padding: 4px 8px;
        color: #ff4949;
        font-size: 12px;
        background: #ffeded;
        border-radius: 3px;
    }
    .ml100{
        margin-left: 100px !important;
    }
    .right_btn_blue{
        color: #ffffff;
        background-color: #1890ff;
        border-color: #1890ff;
    }
    .layui-layer-shade{
        z-index: 1 !important;
    }
    .layui-layer-page{
        z-index: 2 !important;
    }
    .minuteselect,.hourselect{
        min-width: 80px;
    }
    .fds_title{
        font-size: 14px;
        color: #999;
        border: 0;
        border-top: 1px solid #ccc;
        padding: 0;
    }
    .lgd_inner{
        margin: 0 auto;;
        padding: 0 10px;
        width: unset;
        font-size: unset;
        margin-bottom: 20px;
    }
</style>
<div class="main">
    {include file='../../plugin/education/template/web/common_nav'}
<!--    视频显示位置-->
    <form action="" method="post" class="form-horizontal" role="form" name="form5" id="form5">
        <div class="panel panel-default" role="tabpanel"    >
            <div class="panel-heading"><span style="color: red;">*</span>基础设置</div>
            <div class="panel-body">
                <div class="form-horizontal">

<!--                    <div class="form-group">-->
<!--                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>商家分类状态设置</label>-->
<!--                        <div class="col-sm-8 col-xs-12" style="padding-top: 6px;">-->
<!--                            <input  name="open_shangjia_rules" value="0" {if $item['open_shangjia_rules']==0 || !$item['open_shangjia_rules']} checked="checked"{/if} type="radio"> 关闭-->
<!--                            &nbsp;&nbsp;-->
<!--                            <input  name="open_shangjia_rules" value="1" {if $item['open_shangjia_rules']==1 } checked="checked"{/if} type="radio"> 开启-->
<!--                        </div>-->
<!--                    </div>-->



                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>邀请礼品发放条件</label>
                        <div class="col-sm-8 col-xs-12" style="padding-top: 6px;">
                            <input  name="send_gift_type" value="1" {if $item['send_gift_type']==1 || !$item['send_gift_type']} checked="checked"{/if} type="radio"> 支付团满
                            &nbsp;&nbsp;
                            <input  name="send_gift_type" value="2" {if $item['send_gift_type']==2 } checked="checked"{/if} type="radio"> 支付不满团
                            &nbsp;&nbsp;
                            <input  name="send_gift_type" value="3" {if $item['send_gift_type']==3 } checked="checked"{/if} type="radio"> 不支付
                        </div>
                    </div>
                    <!--解锁礼品新样式-->
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>解锁礼品条件选择</label>
                        <div class="col-sm-8 col-xs-12" style="padding-top: 6px;">
                            <input  name="lock_gift_type" value="0" {if $lock_gift_type==0 || !$lock_gift_type} checked="checked"{/if} type="radio"> 成团解锁
                            &nbsp;&nbsp;
                            <input  name="lock_gift_type" value="1" {if $lock_gift_type==1 } checked="checked"{/if} type="radio"> 下单解锁
                            &nbsp;
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>解锁礼品模式选择</label>
                        <div class="col-sm-8 col-xs-12" style="padding-top: 6px;">
                            <input  name="lock_gift_mode" value="0" {if $lock_gift_mode==0 || !$lock_gift_mode} checked="checked"{/if} type="radio"> 解锁可全领取
                            &nbsp;&nbsp;
                            <input  name="lock_gift_mode" value="1" {if $lock_gift_mode==1 } checked="checked"{/if} type="radio"> 解锁选择性领取
                            &nbsp;
                        </div>
                    </div>

                    <div class="form-group" {if !$lock_gift_mode}style="display: none"{/if}>
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">解锁礼品选择数量</label>
                        <div class="col-sm-8 col-xs-12">
                            <div class="input-group">
                                <span class="input-group-addon">最少选择</span>
                                <input  type="number" min=1 step=1 class="form-control"     placeholder="必须为大于0" name="gift_unlock_min_num"  value="{$gift_unlock_min_num}">
                                <span class="input-group-addon">个;最多选择</span>
                                <input type="number" class="form-control" min=1 step=1   placeholder="" name="gift_unlock_max_num"  value="{$gift_unlock_max_num}">
                                <span class="input-group-addon">个;</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="panel panel-default" role="tabpanel">
            <div class="panel-heading">购买设置</div>
            <div class="panel-body">
                <div  class="form-horizontal" >
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>可选课程总数</label>
                        <div class="col-sm-8 col-xs-12">
                            <div class="input-group">
                                <span class="input-group-addon">最少选择</span>
                                <input  type="number" min=1 step=1 class="form-control"  placeholder="必须为大于0" name="course_min_num"  value="{$item['course_min_num']}">
                                <span class="input-group-addon">个;最多选择</span>
                                <input type="number" class="form-control" min=1 step=1  placeholder="" name="course_max_num"  value="{$item['course_max_num']}">
                                <span class="input-group-addon">个;</span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 col-xs-12 control-label">可选赠品数</label>
                        <div class="col-sm-8 col-xs-12">
                            <div class="input-group">
                                <span class="input-group-addon">最少选择</span>
                                <input  type="number" min=1 step=1 class="form-control"  placeholder="必须为大于0" name="gift_min_num"  value="{$item['gift_min_num']}">
                                <span class="input-group-addon">个;最多选择</span>
                                <input type="number" class="form-control" min=1 step=1  placeholder="" name="gift_max_num"  value="{$item['gift_max_num']}">
                                <span class="input-group-addon">个;</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--        定位设置-->
        <div class="panel panel-default" role="tabpanel">
            <div class="panel-heading"><span style="color: red;">*</span>定位设置</div>
            <div class="panel-body">
                <div class="form-horizontal">
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>定位开关</label>
                        <div class="col-sm-8 col-xs-12" style="padding-top: 6px;">
                            <input  name="open_position" value="0" {if $open_position==0 || !$open_position} checked="checked"{/if} type="radio"> 关闭
                            &nbsp;&nbsp;
                            <input  name="open_position" value="1" {if $open_position==1 } checked="checked"{/if} type="radio"> 启用
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 col-xs-12 control-label">定位图标</label>
                        <div class="col-sm-8 col-xs-12">
                            {php echo view_form_field_image('edu_location_img',$edu_location_img);}
                            <span class="help-block">尺寸48*48像素 如：http://img2020.yixuansoft.cn/images/2/2022/07/qCMkMM1r78zVL4zsxS00sGgv4MGsm1.png</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>显示条件</label>
                        <div class="col-sm-4 col-xs-12" style="padding-top: 6px;">
                            <input  name="edu_location_show" value="1" {if $edu_location_show==1 || !$edu_location_show} checked="checked"{/if} type="radio"> 失败后显示,成功后隐藏
                            &nbsp;&nbsp;
                            <input  name="edu_location_show" value="2" {if $edu_location_show==2 } checked="checked"{/if} type="radio"> 一直显示
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">定位提示</label>
                        <div class="col-sm-3 col-xs-12">
                            <div class="input-group">
                                <span class="input-group-addon">默认</span>
                                <input  type="text"
                                        class="form-control"  placeholder="请输入定位提示语" name="edu_location_tips"  value="{$edu_location_tips}">
                            </div>
                        </div>
                        <div class="col-sm-3 col-xs-12">
                            <div class="input-group">
                                <span class="input-group-addon">成功后</span>
                                <input  type="text"
                                        class="form-control"  placeholder="请输入定位成功后提示语" name="edu_success_location_tips"  value="{$edu_success_location_tips}">
                            </div>
                        </div>
                        <div class="col-sm-3 col-xs-12">
                            <div class="input-group">
                                <span class="input-group-addon">字号</span>
                                <input  type="text"
                                        class="form-control"  placeholder="请输入文字大小，默认14像素" name="edu_location_tips_font_size"  value="{$edu_location_tips_font_size}">
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">定位提示语颜色</label>
                        <div class="col-sm-4 col-xs-12">
                            {php echo view_form_field_color('edu_location_bg_color',$edu_location_bg_color);}
                            <span class="help-block">背景颜色：默认灰色</span>
                        </div>
                        <div class="col-sm-4 col-xs-12">
                            {php echo view_form_field_color('edu_location_tips_color',$edu_location_tips_color);}
                            <span class="help-block">文字颜色：默认黑色</span>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <!--        分享与海报-->
        <div class="panel panel-default" role="tabpanel">
            <div class="panel-heading"><span style="color: red;">*</span>分享设置</div>
            <div class="panel-body">
                <div class="form-horizontal">
                    {if !$pn_wxapp}
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>分享条件</label>
                        <div class="col-sm-8 col-xs-12" style="padding-top: 6px;">
                            <input  name="poster_show" value="1" {if $item['poster_show']==1 || !$item['poster_show']} checked="checked"{/if} type="radio"> 不限制
                            &nbsp;&nbsp;
                            <input  name="poster_show" value="2" {if $item['poster_show']==2 } checked="checked"{/if} type="radio"> 付款后分享
                        </div>
                    </div>
                    {/if}
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">分享提示语</label>
                        <div class="col-sm-8 col-xs-12">
                            <div class="input-group">
                                <input  type="text" style="width: 700px;"  class="form-control"  placeholder="请输入分享提示语" name="edu_share_tips"  value="{$edu_share_tips}">
                                <span class="help-block" style="color: red;">通过英文逗号进行分割，换行显示</span>
                            </div>
                        </div>
                    </div>
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-2 col-xs-12 control-label">分享引导图</label>-->
<!--                        <div class="col-sm-8 col-xs-12">-->
<!--                            {php echo view_form_field_image('edu_share_img',$edu_share_img);}-->
<!--                            <span class="help-block"></span>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="form-group share01">-->
<!--                        <label class="col-sm-2 col-xs-12 control-label">海报文字</label>-->
<!--                        <div class="col-sm-8 col-xs-12">-->
<!--                            <textarea rows="5" cols="50" class="form-control"  name="edu_pageshare_txt">{$edu_pageshare_txt}</textarea>-->
<!--                        </div>-->
<!--                    </div>-->
                </div>
            </div>
        </div>


<!--        版权广告-->
        <div class="panel panel-default" role="tabpanel">
            <div class="panel-heading"><span style="color: red;">*</span>版权广告图</div>
            <div class="panel-body">
                <div class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 col-xs-12 control-label">图片</label>
                        <div class="col-sm-8 col-xs-12">
                            {php echo view_form_field_image('btm_img',$item['btm_img']);}
                            <span class="help-block">如：http://img2020.yixuansoft.cn/images/2/2021/12/w4CwoRtUR9r8094iVD9R89rRU2qu2q.jpg/99.jpg</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
<!--        员工提成-->
        {if $config['iscomm']==1}
        <div class="panel panel-default" role="tabpanel">
            <div class="panel-heading"><span style="color: red;">*</span>员工提成设置</div>
            <div class="panel-body">
                <div  class="form-horizontal">
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">团长提成</label>
                        <div class="col-sm-8 col-xs-12">
                            <div class="input-group">
                                <input  type="number" min=1 step=1 class="form-control"  placeholder="必须为大于0" name="group_min_out_price"  value="{$item['group_min_out_price']}">
                                <span class="input-group-addon">元 - </span>
                                <input type="number" class="form-control" min=1 step=1  placeholder="" name="group_max_out_price"  value="{$item['group_max_out_price']}">
                                <span class="input-group-addon">元 </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 col-xs-12 control-label">团员提成</label>
                        <div class="col-sm-8 col-xs-12">
                            <div class="input-group">
                                <input  type="number" min=1 step=1 class="form-control"  placeholder="必须为大于0" name="min_out_price"  value="{$item['min_out_price']}">
                                <span class="input-group-addon">元 - </span>
                                <input type="number" class="form-control" min=1 step=1  placeholder="" name="max_out_price"  value="{$item['max_out_price']}">
                                <span class="input-group-addon">元 </span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {/if}
    </form>

    <div class="form-group" style="width: 120px;position: fixed;right: 30px;bottom: 45%;z-index:1000;">
        <div class="col-sm-12">
            <input name="submit" onclick="addOrEditItem(5)" type="button" value="提交" class="btn btn-primary col-lg-2" style="width: 100px;">
        </div>
    </div>

    <div class="panel panel-default" role="tabpanel" style="margin-top: 60px;">
        <div class="panel-heading">成团奖励设置  <span style="color: dimgray">此奖励为团长专属，可设置一个成团奖</span></div>
        <div class="panel-body">
            <form action="" method="post" class="form-horizontal" role="form" name="form2" id="form2">
                <input type="hidden" name="id" value="{$item['id']}"/>
                <input type="hidden" name="themeid" value="{$themeid}"/>
                <div class="form-group">
                    {if empty($item['tuan'])}
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>选择奖励</label>
                    <div class="col-sm-8 col-xs-12">
                        <select class="form-control" name="gift_id">
                            <option value="0" {if empty($item['tuan']) }selected="selected"{/if}>----------请选择礼品----------</option>
                            {loop $gifts  $val}
                            <option value="{$val['id']}" >{$val['shangjia_name']}-{$val['name']}</option>
                            {/loop}
                        </select>
                    </div>
                    {else}
                    <div style="display: flex;flex-direction: column;">
                        {loop $item['tuan'] $row}
                        {if $row['key']!='价值' && $row['key']!='奖励描述' && $row['key']!='id'}
                        <div style="display: flex;flex-direction: row" class="{if $row['type']=='img'}tuan_div300{else}tuan_div{/if}">
                            <div class="tuan_title" >{$row['key']}</div>
                            <div>
                                {if $row['type']=='img'}
                                <img src="{$row['val']}" style="width: 200px;height: 200px;object-fit: cover;display: inline-block;">
                                {else}
                                {$row['val']}
                                {/if}
                            </div>
                        </div>
                        {/if}
                        {/loop}
                    </div>

                    {/if}
                </div>
                {if empty($item['tuan'])}
                <div class="form-group" id="sub_upload2" >
                    <div class="col-sm-12">
                        <input name="submit" onclick="addOrEditItem(2)" id="btnConfirm2" type="button" value="提交" class="btn btn-primary col-lg-2">
                    </div>
                </div>
                {else}
                <div class="form-group" id="sub_upload2" >
                    <div class="col-sm-12">
                        <input name="submit" onclick="edlTuan()" id="btnConfirm2" type="button" value="删除" class="btn btn-danger col-lg-2">
                    </div>
                </div>
                {/if}
            </form>
        </div>
    </div>
    <div class="panel panel-default" role="tabpanel">
        <div class="panel-heading">解锁奖励设置
            <span style="color: dimgray">此奖励需用户购买后才可进入查看，最多可设置5挡解锁奖</span>
            {if $item_order_count<5}<div class="right_btn" id="open_btn_first">新增解锁奖</div>{/if}
        </div>
        <div class="panel-body">
            <table class="table table-hover">
                <thead class="navbar-inner">
                <tr>
                    <th style="width:50px;">序号</th>
                    <th style="width:180px;">人数</th>
                    <th style="width:120px;">礼品头图</th>
                    <th style="width:120px;">礼品名称</th>
                    <th style="width:120px;">所属商家</th>
                    <th style="width:120px;">状态</th>
                    <th style="width:100px; text-align:right;">操作</th>
                </tr>
                </thead>
                <tbody>
                {loop $item['order'] $i $item}
                <tr class="str_center">
                    <td class="str_center">{php echo $i+1+($pageNumber - 1) * $pageSize;}</td>
                    <td class="str_center">累计邀请<span style="color: #5c99f7">{$item['invite']}</span>人解锁</td>
                    <td class="str_center"><img src="{php echo tomedia($item['img']);}" style="width: 100px;height: 80px;padding: 1px;"></td>
                    <td class="str_center">{$item['name']}</td>
                    <td class="str_center">{$item['shangjia_name']}</td>
                    <td class="str_center">
                        {if $item['invite_status']==1}
                        <span class="label label-danger">下架</span>
                        {else}
                        <span class="label label-success">上架</span>
                        {/if}
                    </td>
                    <td class="str_center" style="text-align:right;">
                        <a class="btn btn-warning btn-sm" onclick="editGiftItem(this)"  data-id="{$i}" data-invite="{$item['invite']}" data-invite_desc="{$item['invite_desc']}" title="编辑"><i class="icon-edit"></i>编辑</a>
                                                <a onclick="DelItem(this)"
                                                   data-edit-url="{php echo createWebUrlPlugin('education.setting.edit');}" data-action="del"
                                                   data-id="{$i}" data-themeid="{$themeid}"  title="删除" style="width: 30px" class="btn btn-danger btn-sm"  data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i></a>
                    </td>
                </tr>
                {/loop}
                </tbody>
            </table>
        </div>
    </div>
    <div class="panel panel-default" role="tabpanel">
        <div class="panel-heading">渠道优惠券  <span style="color: dimgray">配置优惠券玩法，家长可以使用优惠券抵扣支付</span>
            <div class="right_btn right_btn_blue" id="open_btn_coupon">添加优惠券</div></div>
        <div class="panel-body">
            <table class="table table-hover">
                <thead class="navbar-inner">
                <tr style="">
                    <th style="width:50px;">序号</th>
                    <th style="width:120px;text-align: center">名称</th>
                    <th style="width:120px;">金额</th>
                    <th style="width:120px;text-align: center">数量</th>
                    <th style="width:120px;">已领取</th>
                    <th style="width:120px;">已使用</th>
                    <th style="width:120px;">渠道</th>
                    <th style="width:120px;">领券时间</th>
                    <th style="width:120px;">状态</th>
                    <th style="width:100px; text-align:right;">操作</th>
                </tr>
                </thead>
                <tbody>
                {loop $coupon_list $i $item}
                <tr class="str_center">
                    <td class="str_center">{php echo $i+1+($pageNumber - 1) * $pageSize;}</td>
                    <td class="str_center">{$item['name']}</td>
                    <td class="str_center">￥ {$item['price']}</td>
                    <td class="str_center" style="white-space:nowrap;">
                        <a class="btn btn-warning btn-sm" style="white-space: nowrap;" onclick="editItemQty(this)" data-action="add" data-themeid="{$themeid}" data-id="{$item['id']}" title="添加库存" data-toggle="tooltip" data-placement="top" >
                            <i class="fa fa-plus" style="white-space: nowrap;" aria-hidden="true"></i></i>
                        </a>
                        {$item['qty']}
                        {if $item['qty']>0}
                        <a class="btn btn-danger btn-sm" style="white-space: nowrap;" onclick="editItemQty(this)" data-action="minus" data-themeid="{$themeid}" data-id="{$item['id']}" title="减少库存" data-toggle="tooltip" data-placement="top" >
                            <i class="fa fa-minus" style="white-space: nowrap;" aria-hidden="true"></i></i>
                        </a>
                        {/if}
                    </td>
                    <td class="str_center">{$item['get_num']}</td>
                    <td class="str_center">{$item['use_num']}</td>
                    <td class="str_center">{php echo $item['shangjia_name']?$item['shangjia_name']:'全部商家';}</td>
                    <td class="str_center">{$item['get_start_time']} 至 {$item['get_end_time']}</td>
                    <td class="str_center">
                        {if $item['status']==1}
                        <span class="label label-success">正常</span>
                        {elseif $item['status']==0}
                        <span class="label label-default">下架</span>
                        {else}
                        <span class="label label-danger">过期</span>
                        {/if}
                    </td>
                    <td class="str_center" style="text-align:right;">
                        <a class="btn btn-warning btn-sm" onclick="changeOrDelItem(this)" data-action="edit" data-edit-url="{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid,'id'=>$item['id'],'op'=>'get_coupon'));}"  title="编辑"><i class="icon-edit"></i>编辑</a>
                        {if !$item['get_num']}
                        <a onclick="changeOrDelItem(this)"
                           data-edit-url="{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid,'id'=>$item['id'],'op'=>'del_coupon'));}" data-action="del"
                           title="删除" style="width: 30px" class="btn btn-danger btn-sm"  data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i>
                        </a>
                        {/if}
                    </td>
                </tr>
                {/loop}
                </tbody>

            </table>
            {$pager}
        </div>
    </div>

<!--    控制显示隐藏的解锁奖励设置-->
    <form action="" method="post" class="form-horizontal" role="form" name="show_form" style="display:none;width: 600px;margin-top:20px;" id="show_form">
        <input type="hidden" name="themeid" value="{$themeid}"/>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>邀请人数</label>
            <div class="col-sm-8 col-xs-12">
                <input type="text" class="form-control"  placeholder="请输入1-30之间的邀请人数" name="invite_people"  value="{$item['invite_people']}">
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">解锁提示语</label>
            <div class="col-sm-8 col-xs-12">
                <input type="text" class="form-control"  placeholder="请输入解锁提示语" name="invite_desc"  value="{$item['invite_desc']}">
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>选择奖励</label>
            <div class="col-sm-8 col-xs-12">
                <select class="form-control" name="gift_id">
                    <option value="0" selected="selected">----------请选择礼品----------</option>
                    {loop $gifts  $val}
                    <option value="{$val['id']}" >{$val['shangjia_name']}-{$val['name']}</option>
                    {/loop}
                </select>
            </div>
        </div>
        <div class="form-group ml100"  >
            <div class="col-sm-12">
                <input name="submit" onclick="addInvite()"  type="button" value="提交" class="btn btn-primary col-lg-2">
            </div>
        </div>
    </form>
<!--    控制显示隐藏的解锁奖励设置-->
    <!--    控制显示隐藏的解锁奖励修改-->
    <form action="" method="post" class="form-horizontal" role="form" name="show_form" style="display:none;width: 600px;margin-top:20px;" id="show_form_edit">
        <input type="hidden" name="themeid" value="{$themeid}"/>
        <input type="hidden" name="key" id="invite_key" value=""/>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>邀请人数</label>
            <div class="col-sm-8 col-xs-12">
                <input type="text" class="form-control"  placeholder="请输入1-30之间的邀请人数" name="invite_people" id="invite_people_edit"  value="">
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">状态</label>
            <div class="col-sm-8 col-xs-12" style="padding-top: 6px;">
                <input  name="invite_status" value="0"  checked type="radio"> 上架
                &nbsp;&nbsp;
                <input  name="invite_status" value="1"  type="radio"> 下架
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">解锁提示语</label>
            <div class="col-sm-8 col-xs-12">
                <input type="text" class="form-control"  placeholder="请输入解锁提示语" name="invite_desc" id="invite_desc_edit" value="">
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>选择奖励</label>
            <div class="col-sm-8 col-xs-12">
                <select class="form-control" name="gift_id">
                    <option value="0" selected="selected">----------请选择礼品----------</option>
                    {loop $gifts  $val}
                    <option value="{$val['id']}" >{$val['shangjia_name']}-{$val['name']}</option>
                    {/loop}
                </select>
            </div>
        </div>
        <div class="form-group ml100"  >
            <div class="col-sm-12">
                <input name="submit" onclick="editInvite()"  type="button" value="提交" class="btn btn-primary col-lg-2">
            </div>
        </div>
    </form>
    <!--    控制显示隐藏的解锁奖励修改-->

<!--    控制显示隐藏的添加优惠券-->
    <form action="" method="post" class="form-horizontal" role="form" name="show_form1" style="display:none;width: 600px;margin-top:20px;" id="show_form1">
        <input type="hidden" name="themeid" value="{$themeid}"/>
        <input type="hidden" name="coupon_id"  value=""/>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-3 control-label"><span style="color: red;">*</span>名称</label>
            <div class="col-sm-8 col-xs-12">
                <input type="text" class="form-control"  placeholder="请输入优惠券名称" name="name"   value="">
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-3 control-label"><span style="color: red;">*</span>金额</label>
            <div class="col-sm-8 col-xs-12">
                <input type="number" class="form-control"  placeholder="请输入优惠券金额" name="price"   value="">
                <span class="help-block">创建后不能修改，最大值为</span>
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-3 control-label"><span style="color: red;">*</span>数量</label>
            <div class="col-sm-8 col-xs-12">
                <input type="number" class="form-control"  placeholder="请输入优惠券金额" name="qty"   value="">
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-3 control-label"><span style="color: red;">*</span>领取时间</label>
            <div class="col-sm-8 col-xs-12">
                {php echo view_form_field_daterange('get_time', array('start'=>date('Y-m-d H:i:s',$now),'end'=>date('Y-m-d H:i:s',$now)), true);}
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-3 control-label"><span style="color: red;">*</span>使用时间</label>
            <div class="col-sm-8 col-xs-12">
                {php echo view_form_field_daterange('use_time', array('start'=>date('Y-m-d H:i:s',$now),'end'=>date('Y-m-d H:i:s',$now)), true);}
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-4 col-lg-3 control-label"><span style="color: red;">*</span>选择渠道商家</label>
            <div class="col-sm-8 col-xs-12">
<!--                <input type="text" class="form-control"  placeholder=""   id="coupon_shangjia_name" value="">-->
                <input type="hidden" class="form-control"  name="shangjiaid"    value="">
                <select class="form-control" name="shangjiaid" >
                    {loop $shangjia  $val}
                    <option value="{$val['id']}" >{$val['name']}</option>
                    {/loop}
                </select>
                <span class="help-block">创建后不能修改</span>
            </div>
        </div>
        <div class="form-group ml100"  >
            <div class="col-sm-12">
                <input name="submit" onclick="addOrEditCoupon(1)"  type="button" value="提交" class="btn btn-primary col-lg-2">
            </div>
        </div>
    </form>
<!--    控制显示隐藏的添加优惠券-->

<!--    控制显示隐藏的修改优惠券-->
    <form action="" method="post" class="form-horizontal" role="form" name="show_form1" style="display:none;width: 600px;margin-top:20px;" id="show_form2">
        <input type="hidden" name="themeid" value="{$themeid}"/>
        <input type="hidden" name="coupon_id" id="coupon_id" value=""/>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-3 control-label"><span style="color: red;">*</span>名称</label>
            <div class="col-sm-8 col-xs-12">
                <input type="text" class="form-control"  placeholder="请输入优惠券名称" name="name"  id="coupon_name" value="">
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-3 control-label"><span style="color: red;">*</span>金额</label>
            <div class="col-sm-8 col-xs-12">
                <input type="number" class="form-control"  placeholder="请输入优惠券金额" name="price"  id="coupon_price" value="">
                <span class="help-block">创建后不能修改，最大值为</span>
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-3 control-label"><span style="color: red;">*</span>数量</label>
            <div class="col-sm-8 col-xs-12">
                <input type="number" class="form-control"  placeholder="请输入优惠券金额" name="qty"  id="coupon_qty" value="">
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-3 control-label"><span style="color: red;">*</span>领取时间</label>
            <div class="col-sm-8 col-xs-12">
                {if $first_coupon_item}
                {php echo view_form_field_daterange('get_time', array('start'=>$first_coupon_item['get_start_time'],'end'=>$first_coupon_item['get_end_time']), true);}
                {else}
                {php echo view_form_field_daterange('get_time', array('start'=>date('Y-m-d H:i:s',$now),'end'=>date('Y-m-d H:i:s',$now)), true);}
                {/if}
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-3 control-label"><span style="color: red;">*</span>使用时间</label>
            <div class="col-sm-8 col-xs-12">
                {if $first_coupon_item}
                {php echo view_form_field_daterange('use_time', array('start'=>$first_coupon_item['use_start_time'],'end'=>$first_coupon_item['use_end_time']), true);}
                {else}
                {php echo view_form_field_daterange('use_time', array('start'=>date('Y-m-d H:i:s',$now),'end'=>date('Y-m-d H:i:s',$now)), true);}
                {/if}
            </div>
        </div>
        <div class="form-group ml100">
            <label class="col-xs-12 col-sm-4 col-md-4 col-lg-3 control-label"><span style="color: red;">*</span>选择渠道商家</label>
            <div class="col-sm-8 col-xs-12">
                <!--                <input type="text" class="form-control"  placeholder=""   id="coupon_shangjia_name" value="">-->
                <input type="hidden" class="form-control"  name="shangjiaid"   id="shangjiaid1" value="">
                <select class="form-control" name="shangjiaid" id="shangjiaid">
                    {loop $shangjia  $val}
                    <option value="{$val['id']}" >{$val['name']}</option>
                    {/loop}
                </select>
                <span class="help-block">创建后不能修改</span>
            </div>
        </div>
        <div class="form-group ml100"  >
            <div class="col-sm-12">
                <input name="submit" onclick="addOrEditCoupon(2)"  type="button" value="提交" class="btn btn-primary col-lg-2">
            </div>
        </div>
    </form>
<!--    控制显示隐藏的修改优惠券-->
</div>


<script type="text/javascript">
    //新增\修改奖品 提交数据
    function addOrEditItem(no) {
        let postUrl = "{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid));}";
        if (no==1){
            postUrl = "{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid,'op'=>'buy_setting'));}";
        }else if(no==2){
            postUrl = "{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid,'op'=>'tuan_setting'));}";
        }else if (no==3){
            postUrl = "{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid,'op'=>'btm_img_setting'));}";
        }else if (no==4){
            postUrl = "{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid,'op'=>'worker_money_setting'));}";
        }else if (no==5){
            postUrl = "{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid,'op'=>'common_setting'));}";
        }

        let success_redirect = "{php echo createWebUrlPlugin('education.setting',array('themeid'=>$themeid));}";
        var from_no = "#form"+no;
        let formData = $(from_no).serialize();
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:formData,
            success:function (e) {
                let status = e.status;
                let result = e.result;
                if (status!=1){
                    layer.msg(result.msg)
                }else{
                    layer.msg(result.msg);
                    window.location.href = success_redirect;
                }
            },
            fail:function (err) {
                console.log(err)
            }
        })
    }
    //删除成团奖励
    function edlTuan()
    {
        let postUrl = "{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid,'op'=>'del_tuan'));}";
        layer.msg('您确定删除成团奖励设置吗？',{
            btn:['确定','取消'],
            yes:function (index) {
                $.ajax({
                    url:postUrl,
                    dataType:'json',
                    method:'post',
                    data: {},
                    success:function (e) {
                        let res = e.result;
                        let status = e.status;
                        let msg = res.msg;
                        if (status!=1){
                            layer.msg(res.message);
                        }else{
                            layer.msg(msg);
                        }
                        parent.location.reload();
                    },
                    fail:function (err) {
                        console.log(err)
                    }
                });
                // parent.location.reload();
            }
        });
    }
    $("#open_btn_first").on("click",function () {
        var index = layer.open({
            type:1,
            title:['新增解锁奖','font-size:18px;'],
            area:'700px',
            content:$('#show_form')
        })
    });
    $("#open_btn_coupon").on("click",function () {
        var index = layer.open({
            type:1,
            title:['添加优惠券','font-size:18px;'],
            area:'700px',
            content:$('#show_form1')
        })
    });
    //展示修改框
    function editGiftItem(e) {
        let key = e.getAttribute("data-id");
        let invite = e.getAttribute("data-invite");
        let invite_desc = e.getAttribute("data-invite_desc");
        $("#invite_key").val(key);
        $("#invite_people_edit").val(invite);
        $("#invite_desc_edit").val(invite_desc);
        var index = layer.open({
            type:1,
            title:['修改解锁奖','font-size:18px;'],
            area:'700px',
            content:$('#show_form_edit')
        })
    }
    //新增解锁奖
    function addInvite() {
        let postUrl = "{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid,'op'=>'invite_people'));}";
        let success_redirect = "{php echo createWebUrlPlugin('education.setting',array('themeid'=>$themeid));}";
        let formData = $("#show_form").serialize();
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:formData,
            success:function (e) {
                let status = e.status;
                let result = e.result;
                if (status!=1){
                    layer.msg(result.msg)
                }else{
                    layer.msg(result.msg);
                    window.location.href = success_redirect;
                }
            },
            fail:function (err) {
                console.log(err)
            }
        })
    }
    //修改解锁奖
    function editInvite() {
        let postUrl = "{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid,'op'=>'invite_people_edit'));}";
        let success_redirect = "{php echo createWebUrlPlugin('education.setting',array('themeid'=>$themeid));}";
        let formData = $("#show_form_edit").serialize();
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:formData,
            success:function (e) {
                let status = e.status;
                let result = e.result;
                if (status!=1){
                    layer.msg(result.message)
                }else{
                    layer.msg(result.msg);
                    window.location.href = success_redirect;
                }
            },
            fail:function (err) {
                console.log(err)
            }
        })
    }
    //删除解锁奖励
    function DelItem(e) {
        let key = e.getAttribute("data-id");
        let themeid = e.getAttribute("data-themeid");
        let postUrl =e.getAttribute("data-edit-url");
        let op = 'del_order_item';
        layer.msg('您确定删除解锁奖励吗？',{
            btn:['确定','取消'],
            yes:function (index) {
                $.ajax({
                    url:postUrl,
                    dataType:'json',
                    method:'post',
                    data: {key:key,themeid:themeid,op:op},
                    success:function (e) {
                        let res = e.result;
                        let status = res.status;
                        let msg = res.msg;
                        if (status!=1){
                            layer.msg(msg);
                        }else{
                            layer.msg(msg);
                        }
                        window.parent.location.reload();
                    },
                    fail:function (err) {
                        console.log(err)
                    }
                });

            }
        });
    }
    //添加渠道优惠券
    function addOrEditCoupon(no){
        let postUrl = "{php echo createWebUrlPlugin('education.setting.edit',array('themeid'=>$themeid,'op'=>'add_edit_coupon'));}";
        let success_redirect = "{php echo createWebUrlPlugin('education.setting',array('themeid'=>$themeid));}";

        var from_no = "#show_form"+no;
        let formData = $(from_no).serialize();
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:formData,
            success:function (e) {
                let status = e.status;
                let result = e.result;
                if (status!=1){
                    layer.msg(result.msg)
                }else{
                    layer.msg(result.msg);
                    window.location.href = success_redirect;
                }
            },
            fail:function (err) {
                console.log(err)
            }
        })
    }
    //修改删除优惠券
    function changeOrDelItem(e)
    {
        let postUrl =e.getAttribute("data-edit-url");
        let action = e.getAttribute("data-action");
        if (action=='del'){
            layer.msg('您确定删除此优惠券吗？',{
                btn:['确定','取消'],
                yes:function (index) {
                    $.ajax({
                        url:postUrl,
                        dataType:'json',
                        method:'post',
                        data: {},
                        success:function (e) {
                            let res = e.result;
                            let status = res.status;
                            let msg = res.msg;
                            if (status!=1){
                                layer.msg(msg);
                            }else{
                                layer.msg(msg);
                            }
                            window.parent.location.reload();
                        },
                        fail:function (err) {
                            console.log(err)
                        }
                    });
                }
            });
        }else{
            $.ajax({
                url:postUrl,
                dataType:'json',
                method:'post',
                data: {},
                success:function (e) {
                    let res = e.result;
                    let data = res.data;
                    let status = e.status;
                    let msg = res.msg;
                    if (status!=1){
                        layer.msg(msg);
                    }else{
                        $("#shangjiaid").remove();
                        $("#coupon_id").val(data.id);
                        $("#shangjiaid1").val(data.shangjiaid);
                        $("#coupon_name").val(data.name);
                        $("#coupon_price").val(data.price);

                        $('#coupon_name').attr("readonly",true)
                        $('#coupon_price').attr("readonly",true)
                        $("#coupon_qty").val(data.qty);
                        $("#coupon_shangjia_name").val(data.shangjia_name);
                        $('#coupon_shangjia_name').attr("readonly",true);
                        var get_time_str = data.get_start_time+ " 至 "+data.get_end_time;

                        $( "input[name='get_time[start]']").val(data.get_start_time);
                        $( "input[name='get_time[end]']").val(data.get_end_time);
                        $( "input[name='get_time[end]']").siblings(".daterange-time").find("span").html(get_time_str);

                        var use_time_str = data.use_start_time+ " 至 "+data.use_end_time;
                        $( "input[name='use_time[start]']").val(data.use_start_time);
                        $( "input[name='use_time[end]']").val(data.use_end_time);
                        $( "input[name='use_time[end]']").siblings(".daterange-time").find("span").html(use_time_str);

                        var index = layer.open({
                            type:1,
                            title:['修改优惠券','font-size:18px;'],
                            area:'700px',
                            content:$('#show_form2')
                        })
                    }
                },
                fail:function (err) {
                    console.log(err)
                }
            });
        }
    }
    //修改优惠券库存
    function editItemQty(e){
        let action = e.getAttribute("data-action");
        let id = e.getAttribute("data-id");
        let themeid = e.getAttribute("data-themeid");
        var postUrl = "{php echo createWebUrlPlugin('education.setting.edit',array('op'=>'edit_coupon_qty'));}";

        var title_str = '';
        if (action=='add'){
            title_str = '请输入增加库存数';
        }else{
            title_str = '请输入减少库存数';
        }
        layer.prompt({
            formType: 3,
            value: 1,
            title: title_str,
            area: ['300px', '50px'] //自定义文本域宽高
        }, function(value, index, elem){
            layer.close(index);
            $.ajax({
                url:postUrl,
                dataType:'json',
                method:'post',
                data: {coupon_id:id,themeid:themeid,action:action,op_qty:value},
                success:function (e) {
                    let res = e.result;
                    let status = e.status;
                    console.log(status)
                    if (status!=1){
                        layer.msg(res.message);
                    }else{
                        layer.msg(res.msg);
                    }
                    location.reload();
                },
                fail:function (err) {
                    console.log(err)
                }
            });
        });
    }
</script>
